package xyz.robinbingo.leetcode.a20.b06.c09;

import java.util.stream.IntStream;

public class Solution {
    public int translateNum(int num) {
        String s = String.valueOf(num);
        int length = s.length();
        int[] dp = new int[length + 1];
        dp[0] = 1;
        dp[1] = 1;
        IntStream.rangeClosed(2, length).forEach(i -> {
            String temp = s.substring(i - 2, i);
            if (temp.compareTo("10") >= 0 && temp.compareTo("25") <= 0) {
                dp[i] = dp[i - 1] + dp[i - 2];
            } else {
                dp[i] = dp[i - 1];
            }
        });

        return dp[length];
    }
}